import request from '@/modules/index/utils/request';
const store = {
    namespaced: true,
    actions: {
        // 用户列表
        // async userSearch(context, params) {
        //     const data = await request({
        //         url: '/user/search',
        //         method: 'get',
        //     });
        //     return data;
        // },
        // 获取角色管理列表
        async getUserTableList(context, params) {
            const data = await request({
                url: '/sys/user/list',
                method: 'post',
                data: params
            });
            return data;
        },
        // 获取角色管理列表-删除
        async deleteUserTable(context, params) {
            const data = await request({
                url: '/sys/user/delete',
                method: 'post',
                data: params
            });
            return data;
        },
        // 重置密码
        async resetPassword(context, id) {
            const data = await request({
                url: "sys/user/resetPassword/" + id,
                method: 'get',
                data: {}
            });
            return data;
        },
        // 状态改变
        async statusChange(context, params) {
            const data = await request({
                url: "sys/user/updateStatus/" + params.id + "/status/" + params.status,
                method: 'get',
                data: {}
            });
            return data;
        },
        // 新增保存
        async addUser(context, params) {
            const data = await request({
                url: "sys/user/save",
                method: 'post',
                data: params
            });
            return data;
        },
        // 根据id获取user单条数据
        async getUserDataById(context, id) {
            const data = await request({
                url: "sys/user/" + id,
                method: 'get',
                data: {}
            });
            return data;
        },
        // 获取所有角色
        async getAllRole(context, id) {
            const data = await request({
                url: "sys/role/listAll",
                method: 'get',
                data: {}
            });
            return data;
        },
        // 分配角色
        async grantRole(context, params) {
            const data = await request({
                url: "sys/user/grantRole/" + params.id,
                method: 'post',
                data: params.checkedRoles
            });
            return data;
        },
    }
};

export default store;
